package com.meisiabc.app.repository.db.manager;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meisiabc.app.repository.db.entity.Student;
import com.meisiabc.app.repository.db.mapper.StudentMapper;
import org.springframework.stereotype.Service;

@Service
public class StudentManager extends ServiceImpl<StudentMapper, Student> {
    public Student selectByMobile(String mobile) {
        return getOne(new QueryWrapper<Student>().eq("phone", mobile));
    }

    public void updateMobile(String oldMobile, String newMobile) {
        update(Student.builder().phone(newMobile).build(), new QueryWrapper<Student>().eq("phone", oldMobile));
    }


    public Student selectByUnId(String studentId) {
        return getOne(new QueryWrapper<Student>().eq("student_id", studentId).eq("isdeleted", 0));
    }
}
